﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:avalonSearch="clr-namespace:ICSharpCode.AvalonEdit.Search;assembly=ICSharpCode.AvalonEdit">
    <Style TargetType="avalonSearch:SearchPanel">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type avalonSearch:SearchPanel}">
                    
                    <Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" 
                            BorderBrush="{StaticResource HeaderBackgroundBrush}" 
                            BorderThickness="0,0,0,3" 
                            HorizontalAlignment="Right" 
                            VerticalAlignment="Top" 
                            Cursor="Arrow">
                        
                        <StackPanel Orientation="Vertical">
                            
                            <StackPanel Orientation="Horizontal">
                            
                                <TextBox Name="PART_searchTextBox" 
                                         Focusable="True" 
                                         Width="150" 
                                         Height="24" 
                                         Margin="3">
                                    <TextBox.Text>
                                        <Binding Path="SearchPattern" 
                                                 RelativeSource="{RelativeSource TemplatedParent}" 
                                                 UpdateSourceTrigger="PropertyChanged">
                                            <Binding.ValidationRules>
                                                <ExceptionValidationRule />
                                            </Binding.ValidationRules>
                                        </Binding>
                                    </TextBox.Text>
                                </TextBox>                            
                            
                                <Button Command="avalonSearch:SearchCommands.FindPrevious" 
                                        ToolTip="{Binding Localization.FindPreviousText, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Image Width="16" Height="16" Stretch="Fill" Source="/Resources/PreviousAlt.png" />
                                </Button>
                            
                                <Button Command="avalonSearch:SearchCommands.FindNext" 
                                        ToolTip="{Binding Localization.FindNextText, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Image Width="16" Height="16" Stretch="Fill" Source="/Resources/NextAlt.png" />
                                </Button>

                                <Button Command="avalonSearch:SearchCommands.CloseSearchPanel"
                                        ToolTip="Close search panel"
                                        Margin="0,0,3,0">
                                    <Image Width="16" Height="16" Stretch="Fill" Source="/Resources/CloseAlt.png" />
                                </Button>
                            
                            </StackPanel>
                            
                            <StackPanel Orientation="Horizontal">

                                <ToggleButton Margin="3"
                                              ToolTip="Match case"
                                              IsChecked="{Binding MatchCase, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Image Width="16" Height="16" Stretch="Fill" Source="/Resources/MatchCase.png" />
                                </ToggleButton>
                                
                                <ToggleButton Margin="3"
                                              ToolTip="Match whole words"
                                              IsChecked="{Binding WholeWords, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Image Width="16" Height="16" Stretch="Fill" Source="/Resources/MatchWholeWord.png" />
                                </ToggleButton>
                                
                                <ToggleButton Margin="3"
                                              ToolTip="Use regular expression"
                                              IsChecked="{Binding UseRegex, RelativeSource={RelativeSource TemplatedParent}}">
                                    <Image Width="16" Height="16" Stretch="Fill" Source="/Resources/Regex.png" />
                                </ToggleButton>
                                
                            </StackPanel>

                        </StackPanel>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>